BX.namespace("BX.Admin.DraggableTab");BX.Admin.DraggableTab=function(){var t=function(t){if(typeof t!=="object")return;this.moduleId=t.moduleId;this.tabId=t.tabId;this.optionName=t.optionName;this.hidden=t.hidden;this.dragObjects=BX(this.tabId).querySelectorAll('[data-role="dragObj"]');if(typeof this.dragObjects!=="object")return;BX.loadScript("/bitrix/js/main/dd.js");for(var e=0;e<this.dragObjects.length;e++){if(!this.dragObjects[e].hasAttribute("data-onlydest")){var i=BX.findChild(this.dragObjects[e],{className:"draggable"},true,false);i.onbxdragstart=BX.proxy(this.sectionDragStart,this);i.onbxdrag=BX.proxy(this.sectionDragMove,this);i.onbxdragstop=BX.proxy(this.sectionDragStop,this);i.onbxdraghover=BX.proxy(this.sectionDragHover,this);jsDD.registerObject(i);var r=this.dragObjects[e].querySelector('[data-role="toggleObj"]');BX.bind(r,"click",BX.proxy(function(){this.self.toggleHandler(this.dragObj)},{self:this,dragObj:this.dragObjects[e]}))}jsDD.registerDest(this.dragObjects[e],200)}};t.prototype.sectionDragStart=function(){var t=BX.proxy_context.parentNode.parentNode.parentNode;this.bxSectParent=t.parentNode;this.bxSectParentHeight=t.parentNode.offsetHeight;this.bxSectParent.style.height=this.bxSectParentHeight+"px";this.objSectHeight=t.offsetHeight;var e=getComputedStyle(t);var i=e.marginTop;i=i.replace("px","");var r=e.marginBottom;r=r.replace("px","");this.objSectMarginHeight=Number(this.objSectHeight)+Number(i)+Number(r);this.bxSectBlank=this.bxSectParent.insertBefore(BX.create("DIV",{style:{height:"0px"}}),t);this.bxSectBlank1=BX.create("DIV",{style:{height:this.objSectMarginHeight+"px"}});jsDD.disableDest(this.bxSectParent);this.bxSectBlock=BX.create("DIV",{style:{position:"absolute",zIndex:"100",height:this.objSectHeight+"px",width:t.offsetWidth+"px"},children:[t]});this.bxSectPos=BX.pos(this.bxSectParent);this.bxSectParent.appendChild(this.bxSectBlock)};t.prototype.sectionDragMove=function(t,e){e-=this.bxSectPos.top;if(e<0)e=0;if(e>this.bxSectParentHeight-this.objSectHeight)e=this.bxSectParentHeight-this.objSectHeight;this.bxSectBlock.style.top=e+"px"};t.prototype.sectionDragHover=function(t,e,i){var r=BX.proxy_context.parentNode.parentNode.parentNode;if(t==r){this.bxSectParent.insertBefore(this.bxSectBlank1,this.bxSectBlank)}else if(t.parentNode==this.bxSectParent){if(t.nextSibling)this.bxSectParent.insertBefore(this.bxSectBlank1,t.nextSibling);else this.bxSectParent.appendChild(this.bxSectBlank1)}};t.prototype.sectionDragStop=function(){var t=BX.proxy_context.parentNode.parentNode.parentNode;if(this.bxSectBlank1&&this.bxSectBlank1.parentNode==this.bxSectParent){this.bxSectParent.replaceChild(t,this.bxSectBlank1)}else{this.bxSectParent.replaceChild(t,this.bxSectBlank)}this.bxSectParent.style.height="";BX.remove(this.bxSectBlock);BX.remove(this.bxSectBlank);BX.remove(this.bxSectBlank1);jsDD.enableDest(t);var e=this.bxSectParent.querySelectorAll('[data-role="dragObj"]');var i=[];for(var r=0;r<e.length;r++){if(!e[r].hasAttribute("data-onlydest")){if(e[r].hasAttribute("data-id")){i.push(e[r].getAttribute("data-id"))}}}this.dragHandler(i);this.bxSectBlock=null;this.bxSectBlank=null;this.bxSectBlank1=null;this.bxSectParent=null;this.objSectHeight=0;jsDD.refreshDestArea()};t.prototype.dragHandler=function(t){BX.userOptions.save(this.moduleId,this.optionName,"order",t)};t.prototype.toggleHandler=function(t){var e=t.getAttribute("data-id");var i=[];if(BX.hasClass(t,"hidden")){BX.removeClass(t,"hidden");for(var r in this.hidden){if(this.hidden[r]!=e){i.push(this.hidden[r])}else{delete this.hidden[r]}}}else{BX.addClass(t,"hidden");var s=false;for(var r in this.hidden){if(this.hidden[r]==e){s=true;break}}if(!s)this.hidden.push(e);i=this.hidden}BX.userOptions.save(this.moduleId,this.optionName,"hidden",i)};return t}();
//# sourceMappingURL=admin_dd.map.js